package models.dao;

import java.sql.ResultSet;
import java.util.ArrayList;


import model.pojo.TaxType;
import model.util.MySqlDataAccessHelper;

public class TaxTypeDAO {

	public ArrayList<TaxType> taxlst(){
		ArrayList<TaxType> lst = new ArrayList<TaxType>();
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		try{
			mysql.open();
			String ten="TaxTypeDescrVN";
			String sql ="select TaxTypeID,"+ten+" from taxtype";
			ResultSet rs=mysql.executeQuery(sql);
			TaxType cg;
			while(rs.next()){
				cg = new TaxType();
				cg.setTaxTypeID(rs.getString("TaxTypeID"));
				cg.setTaxTypeCode(rs.getString(ten));
			}
			rs.close();
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			mysql.close();
		}
		return lst;
	}
	
	public ArrayList<TaxType> onetax(String id){
		ArrayList<TaxType> lst = new ArrayList<TaxType>();
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		try{
			mysql.open();
			String ten="TaxTypeDescrVN";
			String sql ="select TaxTypeID,"+ten+" from taxtype where TaxTypeID='"+id+"'";
			ResultSet rs=mysql.executeQuery(sql);
			TaxType cg;
			while(rs.next()){
				cg = new TaxType();
				cg.setTaxTypeID(rs.getString("TaxTypeID"));
				cg.setTaxTypeCode(rs.getString(ten));
			}
			rs.close();
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			mysql.close();
		}
		return lst;
	}
}
